<?php 
    namespace Admin\Controller;


    class DiscussController extends AdminController{
       public function index(){
        $map = array();
        if ($_GET['condition']==1) {
        $map['report'] = 1;}
        if ($_GET['condition']==2) {
          $map['display'] = 0;
        }
        // $map['zhihu_discuss.user_id'] = 'user.id';
        $d = D('Discuss');
        $list = $d->where($map)->order('answer_id')->relation(true)->page($_GET['p'], 10)->select();
        $count = $d->where($map)->order('answer_id')->relation(true)->count();;

        $p = new \Think\Page($count,10);// 实例化分页类 传入总记录数和每页显示的记录数

        $p->lastSuffix=false;
        $p->setConfig('header','<p class="rows">共<b>%TOTAL_ROW%</b>条记录&nbsp;&nbsp;每页<b>'.$pagesize.'</b>条&nbsp;&nbsp;第<b>%NOW_PAGE%</b>页/共<b>%TOTAL_PAGE%</b>页</p>');
        $p->setConfig('prev','上一页');
        $p->setConfig('next','下一页');
        $p->setConfig('last','末页');
        $p->setConfig('first','首页');
        $p->setConfig('theme','%FIRST% %UP_PAGE% %LINK_PAGE% %DOWN_PAGE% %END% %HEADER%');

        $show = $p->show();// 分页显示输出
        

        $this->assign('list',$list);
        $this->assign('page',$show);// 赋值分页输出

        $address = '答案评论列表';
        $this->assign('address',$address);
        $this->display('Discuss/index');
       }


       public function ds_display()
       { 
         // var_dump($_GET);exit;
        changedenied($_GET['id'],'display',$_GET['display'],'discuss');

       }
        public function report()
       { 
         // echo $_GET['report'];
        changedenied($_GET['id'],'report',$_GET['report'],'discuss');
        
       }
      


    }